package com.dodo.videoEdit.ui;

import android.content.Intent;

import com.azhon.basic.base.BaseNoModelActivity;
import com.dodo.videoEdit.MyApplication;
import com.dodo.videoEdit.R;
import com.dodo.videoEdit.databinding.ActivityLaunchBinding;
import com.dodo.videoEdit.ui.mainactivity.MainActivity;

import java.util.concurrent.TimeUnit;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;

/**
 * 启动页
 * Created by Super on 2019/12/6.
 */
public class LaunchActivity extends BaseNoModelActivity<ActivityLaunchBinding> {

     private Disposable mDisposable;


    @Override
    protected int onCreate() {
        return R.layout.activity_launch;
    }

    @Override
    protected void initView() {
        if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
            finish();
            return;
        }
        setContentView(R.layout.activity_launch);
        mDisposable = Flowable.timer(3500, TimeUnit.MILLISECONDS)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(next -> {
                    startActivity(new Intent(LaunchActivity.this, MainActivity.class));
                    finish();
                });
        MyApplication.getAppInstance().init();
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mDisposable != null) {
            mDisposable.dispose();
        }
    }

}
